<?php

/*手机归属地查询*/

class Mobile
{
    public static function getMobileAddr($phone)
    {
        $url = 'http://apis.juhe.cn/mobile/get';
        $key = '1af252d171edbe04e872395b52636743';
        $curl = new Curl\Curl();
        $getData = $curl->get($url, array(
            'phone' => $phone,
            'key' => $key,
        ));
        $data = json_decode($getData->response, true);
        if ($data['resultcode'] == 200 && !empty($result = $data['result'])) {
            $res = "手机号码为{$phone},属于{$result['company']}；归属地为：{$result['province']}省 {$result['city']}市；区号为：{$result['areacode']}；邮编：{$result['zip']}";
        } else {
            $res = '手机竟然没信息';
        }
        return $res;
    }
}